<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/9 0009
 * Time: 上午 12:12
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class Area_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }
    /**
     * 查询省,市,县
     * */
    public function getProvince($parentid=0)
    {
        $data = $this->db->get_where('area',['parentid'=>$parentid])->result_array();
        return $data ;
    }
    /**
     * 将获取到的省市县数据组装
     * */
    public function checkData($data)
    {
        //组装
        $new_data = "<option>请选择</option>" ;
        foreach($data as $v)
        {
            $new_data .= "<option value='".$v['areaid']."'>".$v['areaname']."</option>";
        }
        return $new_data;
    }

    /**
     *查询位置
     *@param $areaid 区域id
     * @return 区域的名字
     * */
    public function areaName($areaid)
    {
        $row_data = $this->db->get_where('area',['areaid'=>$areaid])->row_array();
        return $row_data['areaname'];

    }
}